package com.nadi.noda.tech;

import java.util.HashMap;

import android.content.Context;

import com.google.android.gms.analytics.GoogleAnalytics;
import com.google.android.gms.analytics.Logger;
import com.google.android.gms.analytics.Tracker;

public class AnalyticUtils {
	// The following line should be changed to include the correct property id.
	public static final String PROPERTY_ID = "UA-52991128-4";
	public static int GENERAL_TRACKER = 0;

	public enum TrackerName {
		APP_TRACKER, // Tracker used only in this app.
		GLOBAL_TRACKER, // Tracker used by all the apps from a company. eg: roll-up tracking.
		ECOMMERCE_TRACKER, // Tracker used by all ecommerce transactions from a company.
	}

	public static HashMap<TrackerName, Tracker> mTrackers = new HashMap<TrackerName, Tracker>();

	public static synchronized Tracker getTracker(Context context, TrackerName trackerId) {
		if (!mTrackers.containsKey(trackerId)) {
			GoogleAnalytics analytics = GoogleAnalytics.getInstance(context);
			analytics.getLogger().setLogLevel(Logger.LogLevel.VERBOSE);
			Tracker t = analytics.newTracker(PROPERTY_ID);
			t.enableAdvertisingIdCollection(true);
			mTrackers.put(trackerId, t);
		}
		return mTrackers.get(trackerId);
	}
}